<?php

namespace App\Listeners;

use App\Http\Controllers\Miniprograme\SubscribeController;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Modules\Manager\Entities\Manager;

class ReturnPhotoListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        if($event->type==config('wechat.notify.mini.ReturnPhoto')){
            $order = $event->order;
            $name =   $order->license;//Department::query()->where('id',$order->department)->value('name');
            $openid =  Manager::query()
                ->where('post_id',2)
                ->where('id',$order->dispatch_manager)
                ->whereNotNull('openid')
                ->value('openid');

            // if($openid){
            //     (new SubscribeController())->manager($openid,'车管员还车通知','车辆取回',$name.'车辆已取回，请与客户核对费用清单');
            // }
        }
    }
}
